package com.fumihiko.modules.jxxm.service.impl;

import com.fumihiko.modules.jxxm.entity.HonorableEmployeesEntity;
import com.fumihiko.modules.jxxm.entity.RetiredEmployeesEntity;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fumihiko.common.utils.PageUtils;
import com.fumihiko.common.utils.Query;

import com.fumihiko.modules.jxxm.dao.OldWorkerDao;
import com.fumihiko.modules.jxxm.entity.OldWorkerEntity;
import com.fumihiko.modules.jxxm.service.OldWorkerService;


@Service("oldWorkerService")
public class OldWorkerServiceImpl extends ServiceImpl<OldWorkerDao, OldWorkerEntity> implements OldWorkerService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String myStatus = (String)params.get("myStatus");
        String name = (String)params.get("name");
        String idNo = (String)params.get("idNo");
        String personType = (String)params.get("personType");
        String originalTroops = (String)params.get("originalTroops");
        String retirementStatus = (String)params.get("retirementStatus");
        String duties = (String)params.get("duties");
        String county = (String)params.get("county");
        String street = (String)params.get("street");
        String birthDate1 = (String)params.get("birthDate1");
        String birthDate2 = (String)params.get("birthDate2");
        String age1 = (String)params.get("age1");
        String age2 = (String)params.get("age2");
        String retirementTime1 = (String)params.get("retirementTime1");
        String retirementTime2 = (String)params.get("retirementTime2");
        String workTime1 = (String)params.get("workTime1");
        String workTime2 = (String)params.get("workTime2");
        IPage<OldWorkerEntity> page = this.page(
                new Query<OldWorkerEntity>().getPage(params),
                new QueryWrapper<OldWorkerEntity>().
                        eq("state",0).
                        like(StringUtils.isNotBlank(myStatus),"my_status", myStatus).
                        like(StringUtils.isNotBlank(name),"name", name).
                        eq(StringUtils.isNotBlank(idNo),"id_no",idNo).
                        eq(StringUtils.isNotBlank(personType),"person_type",personType).
                        like(StringUtils.isNotBlank(originalTroops),"original_troops", originalTroops).
                        like(StringUtils.isNotBlank(retirementStatus),"retirement_status", retirementStatus).
                        like(StringUtils.isNotBlank(duties),"duties",duties).
                        like(StringUtils.isNotBlank(county),"county", county).
                        like(StringUtils.isNotBlank(street),"street", street).
                        ge(StringUtils.isNotBlank(birthDate1),"birth_date", birthDate1).
                        le(StringUtils.isNotBlank(birthDate2),"birth_date", birthDate2).
                        ge(StringUtils.isNotBlank(retirementTime1),"retirement_time", retirementTime1).
                        le(StringUtils.isNotBlank(retirementTime2),"retirement_time", retirementTime2).
                        ge(StringUtils.isNotBlank(workTime1),"work_time", workTime1).
                        le(StringUtils.isNotBlank(workTime2),"work_time", workTime2)
        );

        return new PageUtils(page);
    }

    @Override
    public PageUtils searchPage(Map<String, Object> params) {
        String myStatus = (String)params.get("myStatus");
        String name = (String)params.get("name");
        String idNo = (String)params.get("idNo");
        String personType = (String)params.get("personType");
        String originalTroops = (String)params.get("originalTroops");
        String retirementStatus = (String)params.get("retirementStatus");
        String duties = (String)params.get("duties");
        String county = (String)params.get("county");
        String street = (String)params.get("street");
        String birthDate1 = (String)params.get("birthDate1");
        String birthDate2 = (String)params.get("birthDate2");
        String age1 = (String)params.get("age1");
        String age2 = (String)params.get("age2");
        String retirementTime1 = (String)params.get("retirementTime1");
        String retirementTime2 = (String)params.get("retirementTime2");
        String workTime1 = (String)params.get("workTime1");
        String workTime2 = (String)params.get("workTime2");
        IPage<OldWorkerEntity> page = this.page(
                new Query<OldWorkerEntity>().getPage(params),
                new QueryWrapper<OldWorkerEntity>().
                        eq("state",0).
                        like(StringUtils.isNotBlank(myStatus),"my_status", myStatus).
                        like(StringUtils.isNotBlank(name),"name", name).
                        eq(StringUtils.isNotBlank(idNo),"id_no",idNo).
                        eq(StringUtils.isNotBlank(personType),"person_type",personType).
                        like(StringUtils.isNotBlank(originalTroops),"original_troops", originalTroops).
                        like(StringUtils.isNotBlank(retirementStatus),"retirement_status", retirementStatus).
                        like(StringUtils.isNotBlank(duties),"duties",duties).
                        like(StringUtils.isNotBlank(county),"county", county).
                        like(StringUtils.isNotBlank(street),"street", street).
                        ge(StringUtils.isNotBlank(birthDate1),"birth_date", birthDate1).
                        le(StringUtils.isNotBlank(birthDate2),"birth_date", birthDate2).
                        ge(StringUtils.isNotBlank(retirementTime1),"retirement_time", retirementTime1).
                        le(StringUtils.isNotBlank(retirementTime2),"retirement_time", retirementTime2).
                        ge(StringUtils.isNotBlank(workTime1),"work_time", workTime1).
                        le(StringUtils.isNotBlank(workTime2),"work_time", workTime2)
        );

        return new PageUtils(page);
    }

    @Override
    public List<OldWorkerEntity> queryErrorPage(Map<String, Object> params) {
        List<OldWorkerEntity> list = new ArrayList<>();
        List<OldWorkerEntity> listAll = baseMapper.getAllList();

        for (int i = 0; i <listAll.size() ; i++) {
            OldWorkerEntity oldWorkerEntity = new OldWorkerEntity();
            OldWorkerEntity re = listAll.get(i);
            //基本信息
            oldWorkerEntity.setPersonalCode(re.getPersonalCode());
            oldWorkerEntity.setName(re.getName());
            oldWorkerEntity.setTotalMonthlyPension(re.getTotalMonthlyPension());
            oldWorkerEntity.setWorkersClassification(re.getWorkersClassification());
            oldWorkerEntity.setCounty(re.getCounty());
            oldWorkerEntity.setStreet(re.getStreet());
            oldWorkerEntity.setHandoverPeriod(re.getHandoverPeriod());
            oldWorkerEntity.setDeath("错误");
            //退休费基数
            Double salaryScale = re.getSalaryScale();//薪级工资
            Double basicSalary = re.getBasicSalary();//基础工资
            Double raiseWages = re.getRaiseWages();//提高工资10%
            Double serviceAllowance = re.getServiceAllowance();//军队服务津贴
            Double difficultySubsidy = re.getDifficultySubsidy();//困难补助
            Double gradeSalary = re.getGradeSalary();//岗位工资
            Double senioritySalary = re.getSenioritySalary();//工龄工资
            Double levelSalary = re.getLevelSalary();//级别工资
            Double bonusAllowance = re.getBonusAllowance();//奖金津贴
            Double seniorityAllowance = re.getSeniorityAllowance();//教护龄津贴
            Double specialTeacherSubsidy = re.getSpecialTeacherSubsidy();//特级老师补贴
            //退休费计发比例
            int txfjfbl = re.getRetirementFeeProportion();
            //提高比例部分
            int tgblbf = re.getIncreaseProportion();
            //工资是否提高10%
            String gzsftg = re.getIsImprove();
            int gzsftgValue = 0;
            if(gzsftg.equals("是"))
            {
                gzsftgValue = 10;
            }
            txfjfbl = txfjfbl + tgblbf + gzsftgValue;

            Double bl = Double.valueOf(txfjfbl);
            bl = bl/100;
            Double sumBasicRe = gradeSalary + salaryScale + serviceAllowance + bonusAllowance + raiseWages + levelSalary;
            sumBasicRe = Math.ceil(sumBasicRe * bl);
            sumBasicRe = sumBasicRe + basicSalary + difficultySubsidy + senioritySalary + seniorityAllowance + specialTeacherSubsidy;

            oldWorkerEntity.setResultA(Double.valueOf(String.format("%.2f", sumBasicRe )));
            //历次增加的退休费合计
            Double retirementPayEightynine = re.getRetirementPayEightynine();//1989年10月增加退休费
            Double retirementPayNinetyfive = re.getRetirementPayNinetyfive();//1995年10月增加退休费
            Double retirementPayNinetynisec = re.getRetirementPayNinetynisec();//1999年10月增加退休费
            Double retirementPayThisec = re.getRetirementPayThisec();//2003年10月增加退休费
            Double retirementPayFirst = re.getRetirementPayFirst();//1993年10月第一步增加退休费
            Double retirementPayNinetyseven = re.getRetirementPayNinetyseven();//1997年7月增加退休费
            Double retirementPayOne = re.getRetirementPayOne();//2001年1月增加退休费
            Double retirementPayThird = re.getRetirementPayThird();//2003年7月增加退休费
            Double retirementPayFourty = re.getRetirementPayFourty();//2014年10月增加退休费
            Double retirementPayNinetytwo = re.getRetirementPayNinetytwo();//1992年3月提高退休费10％
            Double retirementPayNinetysesec = re.getRetirementPayNinetysesec();//1997年10月增加退休费
            Double retirementPayOnsec = re.getRetirementPayOnsec();//2001年10月增加退休费
            Double retirementPayFive = re.getRetirementPayFive();//2005年10月增加退休费
            Double retirementPaySecond = re.getRetirementPaySecond();//1993年10月第二步增加退休费
            Double retirementPayNinetynine = re.getRetirementPayNinetynine();//1999年7月增加退休费
            Double retirementPayOnenew = re.getRetirementPayOnenew();//2001年10月新增退休费
            Double retirementPaySix = re.getRetirementPaySix();//2006年7月增加退休费
            Double pensionSixteen = re.getPensionSixteen();//2016年7月增加离休费
            Double retirementPayEighteen = re.getRetirementPayEighteen();//2018年7月增加离休费
            Double retirementPayTwentyten = re.getRetirementPayTwentyten();//2021年10月增加离休费

            Double sumAddRe = retirementPayEightynine+retirementPayNinetyfive+retirementPayNinetynisec+retirementPayThisec+retirementPayFirst+
                    retirementPayNinetyseven+retirementPayOne+retirementPayThird+retirementPayFourty+retirementPayNinetytwo+retirementPayNinetysesec+
                    retirementPayOnsec+retirementPayFive+retirementPaySecond+retirementPayNinetynine+retirementPayOnenew+retirementPaySix+pensionSixteen+
                    retirementPayEighteen+retirementPayTwentyten;//历次增加的退休费合计
            oldWorkerEntity.setResultB(Double.valueOf(String.format("%.2f", sumAddRe )));
            //价格生活补贴合计
            Double foodAllowanceSeventynine = re.getFoodAllowanceSeventynine();
            Double oilAllowanceNightyone = re.getOilAllowanceNightyone();
            Double fuelLlowance = re.getFuelLlowance();
            Double oilAllowanceNightythird = re.getOilAllowanceNightythird();
            Double livingAllowanceEightyei = re.getLivingAllowanceEightyei();
            Double livingAllowanceNightyfo = re.getLivingAllowanceNightyfo();
            Double foodAllowanceEightyeight = re.getFoodAllowanceEightyeight();
            Double oilAllowanceNightytwo = re.getOilAllowanceNightytwo();
            Double meatLlowance = re.getMeatLlowance();
            Double livingAllowanceEightyfive = re.getLivingAllowanceEightyfive();
            Double livingAllowanceNightytw = re.getLivingAllowanceNightytw();
            Double livingAllowanceNightyfive = re.getLivingAllowanceNightyfive();

            Double sumPrice = foodAllowanceSeventynine + oilAllowanceNightyone + fuelLlowance + oilAllowanceNightythird +
                    livingAllowanceEightyei + livingAllowanceNightyfo + foodAllowanceEightyeight +
                    oilAllowanceNightytwo + meatLlowance + livingAllowanceEightyfive + livingAllowanceNightytw + livingAllowanceNightyfive;//价格生活补贴合计
            oldWorkerEntity.setResultC(Double.valueOf(String.format("%.2f", sumPrice )));
            //增加生活机制（补贴）合计
            Double livingAllowanceSeven = re.getLivingAllowanceSeven();//2007年增加生活补贴
            Double jobSubsidy = re.getJobSubsidy();//2010年职务补贴
            Double ageAllowance = re.getAgeAllowance();//2010年年龄补贴
            Double retirementAllowanceOneo = re.getRetirementAllowanceOneo();//2011年退休补贴
            Double workingYearsSubsidy = re.getWorkingYearsSubsidy();//2012年工作年限补贴
            Double proportionalSubsidy = re.getProportionalSubsidy();//2012年提高比例补贴
            Double growthMechanismThirty = re.getGrowthMechanismThirty();//2013年增长机制补贴
            Double retirementAllowanceOneth = re.getRetirementAllowanceOneth();//2013年退休补贴
            Double retirementAllowanceThirty = re.getRetirementAllowanceThirty();//2014年退休补贴
            Double retirementPayNineteen = re.getRetirementPayNineteen();//2019年1月调整待遇
            Double retirementPayTwentyseven = re.getRetirementPayTwentyseven();//2021年7月增加退休补贴

            Double sumMeleft = livingAllowanceSeven + jobSubsidy + ageAllowance + retirementAllowanceOneo + workingYearsSubsidy + proportionalSubsidy +
                    growthMechanismThirty + retirementAllowanceOneth + retirementAllowanceThirty + retirementPayNineteen + retirementPayTwentyseven;
            oldWorkerEntity.setResultF(Double.valueOf(String.format("%.2f", sumMeleft )));
            //其它合计
            Double paperMoney = re.getPaperMoney();//书报费
            Double bathSubsidy = re.getBathSubsidy();//洗理费
            Double housingSubsidy = re.getHousingSubsidy();//住房补贴
            Double otherIncome = re.getOtherIncome();//其它收入
            Double honorAllowance = re.getHonorAllowance();//荣誉津贴
            Double serviceSubsidy = re.getServiceSubsidy();//物业服务补贴

            Double sumOther = paperMoney + bathSubsidy + housingSubsidy + otherIncome + honorAllowance + serviceSubsidy;
            oldWorkerEntity.setResultG(Double.valueOf(String.format("%.2f", sumOther )));
            //自动生成退休费
            Double sum = sumBasicRe + sumAddRe + sumPrice + sumMeleft + sumOther;
            oldWorkerEntity.setResultH(Double.valueOf(String.format("%.2f", sum)));
            //退休费的差额
            Double total = re.getTotalMonthlyPension();
            Double sumC = total - sum;
            oldWorkerEntity.setResultI(Double.valueOf(String.format("%.2f", sumC)));
            if(sumC >0 || sumC <0)
            {
                list.add(oldWorkerEntity);
            }

        }

        return  list;
    }

    @Override
    public PageUtils queryRepeatPage(Map<String, Object> params) {
        IPage<OldWorkerEntity> page = null;
        List<String> list = baseMapper.queryRepeatList();
        if(list.size() >0)
        {
           page = this.page(
                    new Query<OldWorkerEntity>().getPage(params),
                    new QueryWrapper<OldWorkerEntity>().
                            eq("state",0).in("personal_code",list).orderByAsc("personal_code")
            );
        }else
        {
            page = this.page(
                    new Query<OldWorkerEntity>().getPage(params),
                    new QueryWrapper<OldWorkerEntity>().
                            eq("state",3)
            );
        }

        return new PageUtils(page);
    }

    @Override
    public PageUtils queryDeathPage(Map<String, Object> params) {
        String deathTime1 = (String)params.get("deathTime1");
        String deathTime2 = (String)params.get("deathTime2");
        String logoutDate1 = (String)params.get("logoutDate1");
        String logoutDate2 = (String)params.get("logoutDate2");
        String county = (String)params.get("county");
        String street = (String)params.get("street");

        IPage<OldWorkerEntity> page = this.page(
                new Query<OldWorkerEntity>().getPage(params),
                new QueryWrapper<OldWorkerEntity>().
                        eq("state",0).eq("my_status","死亡").
                        eq(StringUtils.isNotBlank(county),"county", county).
                        eq(StringUtils.isNotBlank(street),"street", street).
                        ge(StringUtils.isNotBlank(deathTime1),"death_time", deathTime1).
                        le(StringUtils.isNotBlank(deathTime2),"death_time", deathTime2).
                        ge(StringUtils.isNotBlank(logoutDate1),"logout_date", logoutDate1).
                        le(StringUtils.isNotBlank(logoutDate2),"logout_date", logoutDate2)
        );

        return new PageUtils(page);
    }

    @Override
    public PageUtils searchDeathPage(Map<String, Object> params) {
        String deathTime1 = (String)params.get("deathTime1");
        String deathTime2 = (String)params.get("deathTime2");
        String logoutDate1 = (String)params.get("logoutDate1");
        String logoutDate2 = (String)params.get("logoutDate2");
        String county = (String)params.get("county");
        String street = (String)params.get("street");

        IPage<OldWorkerEntity> page = this.page(
                new Query<OldWorkerEntity>().getPage(params),
                new QueryWrapper<OldWorkerEntity>().
                        eq("state",0).eq("my_status","死亡").
                        eq(StringUtils.isNotBlank(county),"county", county).
                        eq(StringUtils.isNotBlank(street),"street", street).
                        ge(StringUtils.isNotBlank(deathTime1),"death_time", deathTime1).
                        le(StringUtils.isNotBlank(deathTime2),"death_time", deathTime2).
                        ge(StringUtils.isNotBlank(logoutDate1),"logout_date", logoutDate1).
                        le(StringUtils.isNotBlank(logoutDate2),"logout_date", logoutDate2)
        );

        return new PageUtils(page);
    }

    @Override
    public List<OldWorkerEntity> listDeathExcel(Map<String, Object> params) {
        String deathTime1 = (String)params.get("deathTime1");
        String deathTime2 = (String)params.get("deathTime2");
        String logoutDate1 = (String)params.get("logoutDate1");
        String logoutDate2 = (String)params.get("logoutDate2");
        String county = (String)params.get("county");
        String street = (String)params.get("street");

        QueryWrapper<OldWorkerEntity>  queryWrapper = new QueryWrapper<>();

        queryWrapper.eq("state",0);
        queryWrapper.eq("my_status","死亡");
        queryWrapper.eq(StringUtils.isNotBlank(county),"county", county);
        queryWrapper.eq(StringUtils.isNotBlank(street),"street", street);
        queryWrapper.ge(StringUtils.isNotBlank(deathTime1),"death_time", deathTime1);
        queryWrapper.le(StringUtils.isNotBlank(deathTime2),"death_time", deathTime2);
        queryWrapper.ge(StringUtils.isNotBlank(logoutDate1),"logout_date", logoutDate1);
        queryWrapper.le(StringUtils.isNotBlank(logoutDate2),"logout_date", logoutDate2);

        return baseMapper.listDeathExcel(queryWrapper);
    }

    @Override
    public PageUtils queryDeletePage(Map<String, Object> params) {
        String personalCode = (String)params.get("personalCode");
        String name = (String)params.get("name");
        String idNo = (String)params.get("idNo");


        IPage<OldWorkerEntity> page = this.page(
                new Query<OldWorkerEntity>().getPage(params),
                new QueryWrapper<OldWorkerEntity>().
                        eq("state",1).
                        eq(StringUtils.isNotBlank(personalCode),"personal_code", personalCode).
                        eq(StringUtils.isNotBlank(name),"name", name).
                        eq(StringUtils.isNotBlank(idNo),"id_no", idNo)
        );

        return new PageUtils(page);
    }

    @Override
    public PageUtils searchDeletePage(Map<String, Object> params) {
        String personalCode = (String)params.get("personalCode");
        String name = (String)params.get("name");
        String idNo = (String)params.get("idNo");


        IPage<OldWorkerEntity> page = this.page(
                new Query<OldWorkerEntity>().getPage(params),
                new QueryWrapper<OldWorkerEntity>().
                        eq("state",1).
                        eq(StringUtils.isNotBlank(personalCode),"personal_code", personalCode).
                        eq(StringUtils.isNotBlank(name),"name", name).
                        eq(StringUtils.isNotBlank(idNo),"id_no", idNo)
        );

        return new PageUtils(page);
    }

    @Override
    public void removeByState(Long[] ids) {
        baseMapper.removeByState(ids);
    }

    @Override
    public void recoveryById(Long[] ids) {
        baseMapper.recoveryById(ids);
    }

    @Override
    public List<OldWorkerEntity> listExcel(Map<String, Object> params) {
        List<OldWorkerEntity> list = baseMapper.listExcel();
        List<OldWorkerEntity> listAll = new ArrayList<>();
        for (int i = 0; i < list.size(); i++) {
            OldWorkerEntity oldWorkerEntity = new OldWorkerEntity();
            OldWorkerEntity re = list.get(i);
            oldWorkerEntity.setName(re.getName());//姓名
            oldWorkerEntity.setSex(re.getSex());//性别
            oldWorkerEntity.setWorkTime(re.getWorkTime());//参加工作时间
            oldWorkerEntity.setRetirementTime(re.getRetirementTime());//退休时间

            //退休费基数
            Double senioritySalary = re.getSenioritySalary();//工龄工资
            Double basicSalary = re.getBasicSalary();//基础工资
            Double levelSalary = re.getLevelSalary();//级别工资
            Double gradeSalary = re.getGradeSalary();//岗位工资
            Double bonusAllowance = re.getBonusAllowance();//奖金津贴
            Double seniorityAllowance = re.getSeniorityAllowance();//教护龄津贴
            Double serviceAllowance = re.getServiceAllowance();//军队服务津贴
            Double totalSubsidy = re.getTotalSubsidy();//退休当年职务补贴
            //退休费计发比例
            int txfjfbl = re.getRetirementFeeProportion();
            //提高比例部分
            int tgblbf = re.getIncreaseProportion();
            //工资是否提高10%
            String gzsftg = re.getIsImprove();
            int gzsftgValue = 0;
            if(gzsftg.equals("是"))
            {
                gzsftgValue = 10;
            }
            txfjfbl = txfjfbl + tgblbf + gzsftgValue;

            Double bl = Double.valueOf(txfjfbl);
            bl = bl/100;
            Double sumBasicRe = gradeSalary + serviceAllowance + bonusAllowance + levelSalary;
            sumBasicRe = Math.ceil(sumBasicRe * bl);
            sumBasicRe = sumBasicRe + basicSalary + senioritySalary + seniorityAllowance + totalSubsidy;

            oldWorkerEntity.setResultA(Double.valueOf(String.format("%.2f", sumBasicRe )));

            //历次增加的退休费合计
            Double retirementPayEightynine = re.getRetirementPayEightynine();//1989年10月增加退休费
            Double retirementPayNinetyfive = re.getRetirementPayNinetyfive();//1995年10月增加退休费
            Double retirementPayNinetynisec = re.getRetirementPayNinetynisec();//1999年10月增加退休费
            Double retirementPayThisec = re.getRetirementPayThisec();//2003年10月增加退休费
            Double retirementPayFirst = re.getRetirementPayFirst();//1993年10月第一步增加退休费
            Double retirementPayNinetyseven = re.getRetirementPayNinetyseven();//1997年7月增加退休费
            Double retirementPayOne = re.getRetirementPayOne();//2001年1月增加退休费
            Double retirementPayThird = re.getRetirementPayThird();//2003年7月增加退休费
            Double retirementPayFourty = re.getRetirementPayFourty();//2014年10月增加退休费
            Double retirementPayNinetytwo = re.getRetirementPayNinetytwo();//1992年3月提高退休费10％
            Double retirementPayNinetysesec = re.getRetirementPayNinetysesec();//1997年10月增加退休费
            Double retirementPayOnsec = re.getRetirementPayOnsec();//2001年10月增加退休费
            Double retirementPayFive = re.getRetirementPayFive();//2005年10月增加退休费
            Double retirementPaySecond = re.getRetirementPaySecond();//1993年10月第二步增加退休费
            Double retirementPayNinetynine = re.getRetirementPayNinetynine();//1999年7月增加退休费
            Double retirementPayOnenew = re.getRetirementPayOnenew();//2001年10月新增退休费
            Double retirementPaySix = re.getRetirementPaySix();//2006年7月增加退休费
            Double pensionSixteen = re.getPensionSixteen();//2016年7月增加离休费
            Double retirementPayEighteen = re.getRetirementPayEighteen();//2018年7月增加离休费
            Double retirementPayTwentyten = re.getRetirementPayTwentyten();//2021年10月增加离休费
            Double retirementPayZero = re.getRetirementPayZero();//2000年1月增加退休费

            Double sumAddRe = retirementPayEightynine+retirementPayNinetyfive+retirementPayNinetynisec+retirementPayThisec+retirementPayFirst+
                    retirementPayNinetyseven+retirementPayOne+retirementPayThird+retirementPayFourty+retirementPayNinetytwo+retirementPayNinetysesec+
                    retirementPayOnsec+retirementPayFive+retirementPaySecond+retirementPayNinetynine+retirementPayOnenew+retirementPaySix+pensionSixteen+
                    retirementPayEighteen+retirementPayTwentyten +retirementPayZero;//历次增加的退休费合计
            oldWorkerEntity.setResultB(Double.valueOf(String.format("%.2f", sumAddRe )));

            //价格生活补贴合计
            Double foodAllowanceSeventynine = re.getFoodAllowanceSeventynine();
            Double oilAllowanceNightyone = re.getOilAllowanceNightyone();
            Double livingAllowanceEightyfive = re.getLivingAllowanceEightyfive();

            Double sumPrice = foodAllowanceSeventynine + oilAllowanceNightyone + livingAllowanceEightyfive;//价格生活补贴合计
            oldWorkerEntity.setResultC(Double.valueOf(String.format("%.2f", sumPrice )));

            //增长机制补贴合计
            Double livingAllowanceNightysix = re.getLivingAllowanceNightysix();//1996年增加生活补贴
            Double livingAllowanceNightysev = re.getLivingAllowanceNightysev();//1997年增加生活补贴
            Double livingAllowanceNightyeig = re.getLivingAllowanceNightyeig();//1998年增加生活补贴
            Double livingAllowanceNightynig = re.getLivingAllowanceNightynig();//1999年增加生活补贴
            Double livingAllowanceZero = re.getLivingAllowanceZero();//2000年增加生活补贴
            Double livingAllowanceOne = re.getLivingAllowanceOne();//2001年增加生活补贴
            Double livingAllowanceTwo = re.getLivingAllowanceTwo();//2002年增加生活补贴
            Double livingAllowanceThird = re.getLivingAllowanceThird();//2003年增加机制补贴
            Double livingAllowanceFour = re.getLivingAllowanceFour();//2004年增加机制补贴
            Double livingAllowanceSeven = re.getLivingAllowanceSeven();//2007年增加生活补贴
            Double jobSubsidy = re.getJobSubsidy();//2010年职务补贴

            Double sumLiving = livingAllowanceNightysix + livingAllowanceNightysev + livingAllowanceNightyeig + livingAllowanceNightynig + livingAllowanceZero + livingAllowanceOne +
                    livingAllowanceTwo + livingAllowanceThird + livingAllowanceFour + livingAllowanceSeven + jobSubsidy;
            oldWorkerEntity.setResultI(sumLiving);
            //生活补贴合计
            Double sumG = sumBasicRe + sumAddRe + sumPrice + sumLiving;
            oldWorkerEntity.setResultH(Double.valueOf(String.format("%.2f", sumG)));

            //应发生活补贴合计
            if(list.get(i).getWorkTime() != null && !list.get(i).getWorkTime().equals(""))
            {
                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
                String time =format.format(list.get(i).getWorkTime());

                int nian = Integer.valueOf(time.substring(0,4));
                int month = Integer.valueOf(time.substring(5,7));
                int day = Integer.valueOf(time.substring(8,10));

                Double shbthj =0.0;

                if(nian == 1937 && month > 7 )
                {
                    shbthj = sumG*3.5;
                }else if(nian == 1937 && month == 7 && day >= 7)
                {
                    shbthj = sumG*3.5;
                }else if(nian > 1937 && nian <1943)
                {
                    shbthj = sumG*3.5;
                }else if(nian >= 1943 && nian <1945)
                {
                    shbthj = sumG*3;
                }else if(nian == 1945 && month < 9)
                {
                    shbthj = sumG*3;
                }else if(nian == 1945 && month == 9 && day <= 2)
                {
                    shbthj = sumG*3;
                }else if(nian == 1945 && month == 9 && day >=3 )
                {
                    shbthj = sumG*2;
                }else if(nian == 1945 && month > 9)
                {
                    shbthj = sumG*2;
                }else if(nian > 1945 && nian < 1949)
                {
                    shbthj = sumG*2;
                }else if(nian == 1949 && month < 10)
                {
                    shbthj = sumG*2;
                }
                oldWorkerEntity.setResultG(Double.valueOf(String.format("%.2f", shbthj)));
            }
            oldWorkerEntity.setStreet(re.getStreet());
            listAll.add(oldWorkerEntity);
        }
        return listAll;
    }

    @Override
    public List<OldWorkerEntity> getName(String query) {
        return baseMapper.getName(query);
    }

}
